package com.googlecode.monitoria.client.to;

import com.extjs.gxt.ui.client.data.BaseTreeModel;
import com.googlecode.monitoria.client.beans.User;
import com.googlecode.monitoria.client.beans.UserType;

/**
 * 
 * @author Ricardo Araújo Santos - ricardo@lsd.ufcg.edu.br
 */
public class UserTO extends BaseTreeModel{
	
	public static final String NAME = "name";
	public static final String PASSWORD = "password";
	public static final String TYPE = "type";

	/**
	 * 
	 */
	private static final long serialVersionUID = 1564127384494161795L;

	/**
	 * Default empty constructor.
	 */
	public UserTO() {
		super();
	}
	
	/**
	 * @param user
	 */
	public UserTO(User user){
		this(user.getName(), user.getPassword(), user.getType().toString());
	}

	/**
	 * Default constructor using fields.
	 * @param name User name.
	 * @param password Password.
	 * @param userType User type according to {@link UserType}.
	 */
	public UserTO(String name, String password, String userType) {
		super();
		setName(name);
		setPassword(password);
		setType(userType);
	}

	/**
	 * @return the name
	 */
	public String getName() {
	
		return get(NAME);
	}

	/**
	 * @param name the name to set
	 */
	public void setName( String name ) {
	
		set(NAME, name);
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
	
		return get(PASSWORD);
	}

	/**
	 * @param password the password to set
	 */
	public void setPassword( String password ) {
	
		set(PASSWORD, password);
	}

	/**
	 * @return the type
	 */
	public String getType() {
	
		return get(TYPE);
	}

	/**
	 * @param userType the type to set
	 */
	public void setType( String userType ) {
	
		set(TYPE, userType);
	}

	@Override
	public String toString() {
		return "Name: " + getName();
	}
}
